package kr.hkit.powerjava.homework2;

import java.util.Arrays;

public class Person implements Comparable{

	private String name;
	private int hight;
	
	public Person(String name, int hight) {
		this.name = name;
		this.hight = hight;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getHight() {
		return hight;
	}
	public void setHight(int hight) {
		this.hight = hight;
	}
	
//	@Override
//	public int compareTo(Object other) {
//		// TODO Auto-generated method stub
//		return hig);
//	}

//	@Override
//	public int compareTo(Comparable o) {
//		// TODO Auto-generated method stub
//		return hight-o.;
//	}
	
	@Override
	public String toString() {
		return "Person [name=" + name + ", hight=" + hight + "]";
	}	
	public static void main(String[] args) {
		Person[] per1 = new Person[3];
		per1[0] = new Person("우석1", 165);
		per1[1] = new Person("우석2", 170);
		per1[2] = new Person("우석3", 120);
		
		for (int i = 0; i < per1.length; i++) {
			System.out.println(per1[i]);
		}
		getMaximum(per1);
	}

//	public static String getMaximum(Person[] array){
//		Arrays.sort(array);
//		return array[array.length-1].getName();
//	}
@Override
public int compare(Person o) {
	// TODO Auto-generated method stub
	return hight-o.hight;
}
public static void getMaximum(Person[] array){
	  int maxHeight=0;
	   for (int i = 0; i < array.length; i++) {
	    if(array[maxHeight].compare(array[i])<0){
	    maxHeight = i;
	   }
	  }
	    System.out.println("키가 제일 큰 사람은 "+array[maxHeight].name+"이다.");
}
}
